<extend name="Layout:layout"/>

<block name="css">
    <link rel="stylesheet" href="">
    <link rel="stylesheet" href="__PUBLIC__/metis/assets/lib/datatables/3/dataTables.bootstrap.css">
</block>

<block name="srcjs">
    <script type="text/javascript" src=""></script>
</block>

<block name="content">

    <h3>学员列表</h3>
    <hr>

    <div class="row ui-sortable">
        <div class="col-lg-12">

            <div class="row">
                <div class="col-lg-12">
                    <div class="box">
                        <header>
                            <div class="icons"> <i class="fa fa-table"></i>
                            </div>
                            <h5>员工列表</h5>
                            <div class="text-right" style="padding: 5px 10px 0px 0px">
                                <!--<button type="button" id="btnExportReportData" class="btn btn-default btn-sm">导出</button>-->
                            </div>
                        </header>
                        <div class="body">
                            <table id="membersTable" class="table table-bordered table-condensed table-hover table-striped text-center">
                                <thead>
                                    <tr>
                                        <th class="text-center">#</th>
                                        <th class="text-center">员工编号</th>
                                        <th class="text-center">姓名</th>
                                        <th class="text-center">电话</th>
                                        <th class="text-center">情况</th>
                                        <th class="text-center">注册时间</th>
                                        <th class="text-center">批准时间</th>
                                        <th class="text-center">操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                <volist name="members" id="member" key="k">
                                    
                                    <if condition="$member['is_del'] == 0" >
                                        <tr>
                                    <else/>
                                        <tr style="color: #888; text-decoration:line-through;">
                                    </if>
                                    
                                        
                                        <td>{$k}</td>
                                        <td>{$member.username}</td>
                                        <td>{$member.real_name}</td>
                                        <td>{$member.tel}</td>
                                        <td>{$member.status}</td>
                                        <td>{$member.create_time}</td>
                                        <td>{$member.approve_time}</td>
                                        
                                        
                                        
                                        <td>
                                            <if condition=" $_SESSION['current_user']['group_id'] == 1 ">
                                                <if condition="$member['is_del'] == 0" >
                                                    <button 
                                                        class="btn btn-defalut btn-xs"
                                                        data-name="btnCancelMember"
                                                        data-member-uid="{$member.id}"
                                                        data-member-username="{$member.username}"
                                                        >
                                                        删除
                                                    </button>
                                                
                                                <else/>
                                                
                                                <button 
                                                        class="btn btn-default btn-xs"
                                                        data-name="btnResetMember"
                                                        data-member-uid="{$member.id}"
                                                        data-member-username="{$member.username}"
                                                        >
                                                        撤销
                                                    </button>
                                                    <button 
                                                        class="btn btn-danger btn-xs"
                                                        data-name="btnDelMember"
                                                        data-member-uid="{$member.id}"
                                                        data-member-username="{$member.username}"
                                                        >
                                                        彻底删除
                                                    </button>
                                                </if>
                                                
                                            </if>
                                        </td>

                                    </tr>
                                </volist>

                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
            <!-- /.row -->
        </div>
    </div>
</block>

<block name="customjs">
    
    <script src="__PUBLIC__/metis/assets/lib/datatables/jquery.dataTables.js"></script>
    <script src="__PUBLIC__/metis/assets/lib/datatables/3/dataTables.bootstrap.js"></script>

    
    <script>
        $(function () {

            $('#membersTable').dataTable({
                "scrollX": true,
                "language": dtChinese
            });
            
            $("#membersTable").delegate("[data-name='btnDelMember']", "click", function () {
                
                if(!confirm("是否要删除？")){
                    return;
                }
                
                var id = $(this).attr("data-member-uid");
                var sendData = {"id" : id};
                
                $.post("{:U('delMemberInfo')}",sendData).done(function(responseData){
                    if (responseData.status === 1) {
                        alert(responseData.info);
                        location.href = responseData.jumpUrl;
                    } else {
                        alert(responseData.info);
                    }
                });
            });
            
            $("#membersTable").delegate("[data-name='btnCancelMember']", "click", function () {
                
                if(!confirm("是否要删除？")){
                    return;
                }
                
                var id = $(this).attr("data-member-uid");
                var sendData = {"id" : id};
                
                $.post("{:U('cancelMemberInfo')}",sendData).done(function(responseData){
                    if (responseData.status === 1) {
                        alert(responseData.info);
                        location.href = responseData.jumpUrl;
                    } else {
                        alert(responseData.info);
                    }
                });
            });
            
            $("#membersTable").delegate("[data-name='btnResetMember']", "click", function () {
                
                if(!confirm("是否要撤销？")){
                    return;
                }
                
                var id = $(this).attr("data-member-uid");
                var sendData = {"id" : id};
                
                $.post("{:U('resetMemberInfo')}",sendData).done(function(responseData){
                    if (responseData.status === 1) {
                        alert(responseData.info);
                        location.href = responseData.jumpUrl;
                    } else {
                        alert(responseData.info);
                    }
                });
            });
            
            

        });

    </script>
</block>
